package com.cobra.rdd.operator.transform

import org.apache.spark.{SparkConf, SparkContext}

//获取每个分区的最大值
object Spark07_RDD_Operator_Transform_flat_map_test {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("mapPartitionsWithIndex")
    val sc = new SparkContext(sparkConf)
    val rdd = sc.makeRDD(List(List(1,2),3,List(3,4)))
    val flatRDD = rdd.flatMap(
      data => {
        data match {
          case list:List[_] => list
          case dat => List(dat)
        }
      }
    )
    flatRDD.collect().foreach(println)
    sc.stop()
  }
}
